package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.myapplication.utils.DateUtil;

public class SecondActivity extends AppCompatActivity {

    private TextView content;;
    private Button back;
    private TextView tv_return;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);

        content = findViewById(R.id.content);
        tv_return = findViewById(R.id.tv_return);
        back = findViewById(R.id.back);

        //获取消息
//        String request_content = getIntent().getExtras().getString("request_content");
//        String request_time = getIntent().getExtras().getString("request_time");
//        String desc= String.format("接受到的消息为:%s\n接受到时间为:%s", request_content,request_time);
//        content.setText(desc);

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                Bundle bundle=new Bundle();
                bundle.putString("return_content",(String) tv_return.getText());
//                Log.d("1111", (String) tv_return.getText());

                bundle.putString("request_time", DateUtil.getNowtime());
                intent.putExtras(bundle);
                //返回消息设置
                setResult(Activity.RESULT_OK,intent);
                finish();
            }
        });
    }



}